<!--Copyright (C) Kherty.  All rights reserved.-->
<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:chart="http://schemas.Kherty.com/office/2007/chart"
    xmlns:chartui="clr-namespace:OpenLS.Chart.UI"
    xmlns:drawing2="clr-namespace:OpenLS.Drawing.UI;assembly=OpenLS.Drawing.UI"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:Internals="clr-namespace:OpenLS.Chart.UI.Internals"
    xmlns:System="clr-namespace:System;assembly=mscorlib"
    x:Class="OpenLS.Chart.UI.Bar3DChartResources"
    >
    <ResourceDictionary.MergedDictionaries>
        <chartui:Chart3DViewportResources/>
        <chartui:Axis3DResources/>
    </ResourceDictionary.MergedDictionaries>

    <DataTemplate DataType="{x:Type chart:Bar3DChart}" >
        <Grid Focusable="True" Name="bar3DGrid"
                   MouseDown="Panel_MouseDown" 
                   chartui:ChartElement.Chart="{Binding}"
                   chartui:ChartElement.ShapePropertiesObserver="{Binding Converter={x:Static Internals:ChartConverters.ShapePropertiesObserverFactory}}"
                   Background="Transparent">
            <Grid.CommandBindings>
                <CommandBinding Command="{x:Static chartui:ChartCommands.FormatDataSeries}" Executed="OnFormatDataSeries"/>
                <CommandBinding Command="{x:Static chartui:ChartCommands.Format3DRotation}" Executed="OnFormat3DRotation"/>
                <CommandBinding Command="{x:Static chartui:ChartCommands.FormatFloor}" Executed="OnFormatFloor"/>
                <CommandBinding Command="{x:Static chartui:ChartCommands.FormatWalls}" Executed="OnFormatWalls"/>
            </Grid.CommandBindings> 
            <Grid.ContextMenu>
                <ContextMenu>
                    <MenuItem Command="{x:Static chartui:ChartCommands.UnformatDataSeries}"/>
                    <MenuItem Command="{x:Static chartui:ChartCommands.FormatDataSeries}"/>
                    <MenuItem Command="{x:Static chartui:ChartCommands.FormatFloor}"/>
                    <MenuItem Command="{x:Static chartui:ChartCommands.FormatWalls}"/>
                    <MenuItem Command="{x:Static chartui:ChartCommands.Format3DRotation}" />
                </ContextMenu>
            </Grid.ContextMenu>
            <chartui:ChartElement.Observer>
                <MultiBinding Converter="{x:Static Internals:ChartConverters.SeriesObserverFactory}">
                    <Binding Path="Series"/>
                    <Binding Path="Grouping"/>
                </MultiBinding>
            </chartui:ChartElement.Observer>
            <chartui:ChartElement.ZAxisInfo>
                <MultiBinding Converter="{x:Static Internals:ChartConverters.CountAndGroupingToZAxisInfoConverter}">
                    <Binding Path="(chartui:ChartElement.Chart).Series.Count"  RelativeSource="{RelativeSource Self}"/>
                    <Binding Path="(chartui:ChartElement.Chart).Grouping" RelativeSource="{RelativeSource Self}"/>
                </MultiBinding>
            </chartui:ChartElement.ZAxisInfo>
            <chartui:ChartElement.ChartInfo>
                <MultiBinding Converter="{x:Static Internals:ChartConverters.ChartInfoFactory}">
                    <Binding Path="(chartui:ChartElement.XAxisInfo).Minimum" RelativeSource="{RelativeSource Self}"/>
                    <Binding Path="(chartui:ChartElement.XAxisInfo).Maximum" RelativeSource="{RelativeSource Self}"/>
                    <Binding Path="(chartui:ChartElement.YAxisInfo).Minimum" RelativeSource="{RelativeSource Self}"/>
                    <Binding Path="(chartui:ChartElement.YAxisInfo).Maximum" RelativeSource="{RelativeSource Self}"/>
                    <Binding Path="(chartui:ChartElement.ZAxisInfo).Minimum" RelativeSource="{RelativeSource Self}"/>
                    <Binding Path="(chartui:ChartElement.ZAxisInfo).Maximum" RelativeSource="{RelativeSource Self}"/>
                </MultiBinding>
            </chartui:ChartElement.ChartInfo>
            <chartui:Chart3DElement.Projector>
                <MultiBinding Converter="{x:Static Internals:ChartConverters.ProjectorFactory}">
                    <Binding RelativeSource="{RelativeSource Self}" Path="(chartui:ChartElement.ChartArea).View3D.RotationX" />
                    <Binding RelativeSource="{RelativeSource Self}" Path="(chartui:ChartElement.ChartArea).View3D.RotationY" />
                    <Binding RelativeSource="{RelativeSource Self}" Path="(chartui:ChartElement.XAxisInfo).Minimum"/>
                    <Binding RelativeSource="{RelativeSource Self}" Path="(chartui:ChartElement.XAxisInfo).Maximum"/>
                    <Binding RelativeSource="{RelativeSource Self}" Path="(chartui:ChartElement.YAxisInfo).Minimum"/>
                    <Binding RelativeSource="{RelativeSource Self}" Path="(chartui:ChartElement.YAxisInfo).Maximum"/>
                    <Binding RelativeSource="{RelativeSource Self}" Path="(chartui:ChartElement.ZAxisInfo).Minimum"/>
                    <Binding RelativeSource="{RelativeSource Self}" Path="(chartui:ChartElement.ZAxisInfo).Maximum"/>
                    <Binding RelativeSource="{RelativeSource Self}" Path="ActualWidth"/>
                    <Binding RelativeSource="{RelativeSource Self}" Path="ActualHeight"/>
                    <Binding RelativeSource="{RelativeSource Self}" Path="(chartui:ChartElement.ChartArea)" />
                </MultiBinding>
            </chartui:Chart3DElement.Projector>


            <ContentPresenter Content="{Binding}" ContentTemplate="{x:Static chartui:ChartBackgroundResources.ChartSurfacesTemplate}"/>
            <ContentPresenter Name="valueAxis"
                Content="{Binding ValueAxis}" ContentTemplate="{x:Static chartui:ValueAxis3DResources.ValueAxis3DTemplate}">
            </ContentPresenter>
            <Grid Name="valueGridLines">
                <ContentPresenter Name="minorValueGridLines" ContentTemplate="{x:Static chartui:ChartLine3DResources.ChartLineInfoTemplate}">
                    <chartui:AxisElement.MinorStep>
                        <MultiBinding Converter="{x:Static Internals:ChartConverters.MinMaxToMinorStepConverter}">
                            <Binding RelativeSource="{RelativeSource Self}" Path="(chartui:AxisElement.Minimum)"/>
                            <Binding RelativeSource="{RelativeSource Self}" Path="(chartui:AxisElement.Maximum)"/>
                        </MultiBinding>
                    </chartui:AxisElement.MinorStep>
                    <ContentPresenter.Content>
                        <MultiBinding Converter="{x:Static Internals:ChartConverters.MinMaxToMinorInfoConverter}">
                            <Binding RelativeSource="{RelativeSource Self}" Path="(chartui:AxisElement.Minimum)"/>
                            <Binding RelativeSource="{RelativeSource Self}" Path="(chartui:AxisElement.Maximum)"/>
                            <Binding RelativeSource="{RelativeSource Self}" Path="(chartui:AxisElement.MinorStep)"/>
                            <Binding Path="ValueAxis"/>
                            <Binding Path="ValueAxis.MinorGridLines"/>
                        </MultiBinding>
                    </ContentPresenter.Content>
                </ContentPresenter>
                <ContentPresenter ContentTemplate="{x:Static chartui:ChartLine3DResources.ChartLineInfoTemplate}">
                    <chartui:AxisElement.MajorStep>
                        <MultiBinding Converter="{x:Static Internals:ChartConverters.MinMaxToMajorStepConverter}">
                            <Binding RelativeSource="{RelativeSource Self}" Path="(chartui:AxisElement.Minimum)"/>
                            <Binding RelativeSource="{RelativeSource Self}" Path="(chartui:AxisElement.Maximum)"/>
                        </MultiBinding>
                    </chartui:AxisElement.MajorStep>
                    <ContentPresenter.Content>
                        <MultiBinding Converter="{x:Static Internals:ChartConverters.MinMaxToMajorInfoConverter}">
                            <Binding RelativeSource="{RelativeSource Self}" Path="(chartui:AxisElement.Minimum)"/>
                            <Binding RelativeSource="{RelativeSource Self}" Path="(chartui:AxisElement.Maximum)"/>
                            <Binding RelativeSource="{RelativeSource Self}" Path="(chartui:AxisElement.MajorStep)"/>
                            <Binding Path="ValueAxis"/>
                            <Binding Path="ValueAxis.MajorGridLines"/>
                        </MultiBinding>
                    </ContentPresenter.Content>
                </ContentPresenter>
            </Grid>
            <ContentPresenter ContentTemplate="{x:Static chartui:ChartLine3DResources.OutlineTemplate}"/>

            <Viewport3D  Name="vp" Style="{x:Static chartui:Chart3DViewportResources.Chart3DViewportStyle}">
                <ModelVisual3D>
                    <ModelVisual3D.Content>
                        <AmbientLight Color="#555555" />
                    </ModelVisual3D.Content>
                </ModelVisual3D>
                <ModelVisual3D>
                    <ModelVisual3D.Content>
                        <DirectionalLight Color="Gray" Direction="-1,-1,-1" />
                    </ModelVisual3D.Content>
                </ModelVisual3D>
                <ModelVisual3D>
                    <ModelVisual3D.Content>
                        <DirectionalLight Color="White" Direction="0, 0, -1" />
                    </ModelVisual3D.Content>
                </ModelVisual3D>

                <ModelVisual3D>
                    <ModelVisual3D.Content>
                        <MultiBinding Converter="{x:Static Internals:ChartConverters.Bar3DModelFactory}">
                            <Binding Path="Series"/>
                            <Binding Path="(drawing2:DrawingElement.Theme).ColorScheme" ElementName="vp" />
                            <Binding Path="(chartui:ChartElement.Style)" ElementName="vp"  />
                            <Binding Path="VaryColors"/>
                            <Binding Path="Shape"/>
                            <Binding Path="Grouping"/>
                            <Binding Path="GapWidth"/>
                            <Binding Path="(chartui:ChartElement.YAxisInfo).Minimum" ElementName="vp" />
                            <Binding Path="(chartui:ChartElement.YAxisInfo).Maximum" ElementName="vp" />
                            <Binding Path="SeriesAxis.CrossesAt"/>
                            <Binding Path="SeriesAxis.Crosses"/>
                            <Binding Path="Direction"></Binding>
<!--                            <Binding Path="(chartui:ChartElement.YMinimum)" ElementName="vp" />
                            <Binding Path="(chartui:ChartElement.YMaximum)" ElementName="vp" /> -->
                            <Binding Path="(chartui:ChartElement.Observer).Generation" ElementName="vp"/>
                            <Binding Path="(chartui:ChartElement.Observer)" ElementName="vp"/>
                            <Binding ElementName="vp" Path="(chartui:ChartElement.ShapePropertiesObserver).Generation"></Binding>
                        </MultiBinding>
                    </ModelVisual3D.Content>
                </ModelVisual3D>
                
            </Viewport3D>
        </Grid>
        <DataTemplate.Triggers>
            <DataTrigger Binding="{Binding Direction}" Value="{x:Static chart:BarDirection.Column}">
                <Setter TargetName="valueAxis" Property="chartui:AxisElement.Minimum" Value="{Binding RelativeSource={RelativeSource Self}, Path=(chartui:ChartElement.YAxisInfo).Minimum}"/>
                <Setter TargetName="valueAxis" Property="chartui:AxisElement.Maximum" Value="{Binding RelativeSource={RelativeSource Self}, Path=(chartui:ChartElement.YAxisInfo).Maximum}"/>

                <Setter TargetName="valueGridLines" Property="chartui:AxisElement.Minimum" Value="{Binding RelativeSource={RelativeSource Self}, Path=(chartui:ChartElement.YAxisInfo).Minimum}"/>
                <Setter TargetName="valueGridLines" Property="chartui:AxisElement.Maximum" Value="{Binding RelativeSource={RelativeSource Self}, Path=(chartui:ChartElement.YAxisInfo).Maximum}"/>
                <Setter TargetName="bar3DGrid" Property="chartui:ChartElement.XAxisInfo" Value="{Binding Path=Categories.Values.Count, Converter={x:Static Internals:ChartConverters.SimpleAxisInfoFactory}}"/>
                <Setter TargetName="bar3DGrid" Property="chartui:ChartElement.YAxisInfo" >
                    <Setter.Value>
                <MultiBinding Converter="{x:Static Internals:ChartConverters.Axis3DInfoFactory}" >
                            <Binding Path="SeriesAxis.CrossesAt"/>
                            <Binding Path="ValueAxis.Minimum" />
                            <Binding Path="ValueAxis.Maximum" />
                    <Binding Path="(chartui:ChartElement.Observer).ActualMinimum" RelativeSource="{RelativeSource Self}"/>
                    <Binding Path="(chartui:ChartElement.Observer).Maximum" RelativeSource="{RelativeSource Self}"/>
                </MultiBinding>
                    </Setter.Value>
                </Setter>
            </DataTrigger>
            <DataTrigger Binding="{Binding Direction}" Value="{x:Static chart:BarDirection.Bar}">
                <Setter TargetName="valueAxis" Property="chartui:AxisElement.Minimum" Value="{Binding RelativeSource={RelativeSource Self}, Path=(chartui:ChartElement.XAxisInfo).Minimum}"/>
                <Setter TargetName="valueAxis" Property="chartui:AxisElement.Maximum" Value="{Binding RelativeSource={RelativeSource Self}, Path=(chartui:ChartElement.XAxisInfo).Maximum}"/>

                <Setter TargetName="valueGridLines" Property="chartui:AxisElement.Minimum" Value="{Binding RelativeSource={RelativeSource Self}, Path=(chartui:ChartElement.XAxisInfo).Minimum}"/>
                <Setter TargetName="valueGridLines" Property="chartui:AxisElement.Maximum" Value="{Binding RelativeSource={RelativeSource Self}, Path=(chartui:ChartElement.XAxisInfo).Maximum}"/>
                
                <Setter TargetName="bar3DGrid" Property="chartui:ChartElement.YAxisInfo">
                    <Setter.Value>
                        <MultiBinding Converter="{x:Static Internals:ChartConverters.AxisInfoFactory}">
                            <Binding>
                                <Binding.Source>
                                    <System:Double>0</System:Double>
                                </Binding.Source>
                            </Binding>
                            <Binding  Path="Categories.Values.Count"></Binding>
                            <Binding>
                                <Binding.Source>
                                    <System:Double>0</System:Double>
                                </Binding.Source>
                            </Binding>
                            <Binding  Path="Categories.Values.Count"></Binding>
                        </MultiBinding>
                    </Setter.Value>
                </Setter>
                <Setter TargetName="bar3DGrid" Property="chartui:ChartElement.XAxisInfo">
                    <Setter.Value>
                        <MultiBinding Converter="{x:Static Internals:ChartConverters.AxisInfoFactory}">
                            <Binding Path="ValueAxis.Minimum"/>
                            <Binding Path="ValueAxis.Maximum"/>
                            <Binding Path="(chartui:ChartElement.Observer).Minimum" RelativeSource="{RelativeSource Self}"/>
                            <Binding Path="(chartui:ChartElement.Observer).Maximum" RelativeSource="{RelativeSource Self}"/>
                        </MultiBinding>
                    </Setter.Value>
                </Setter>
            </DataTrigger>
        </DataTemplate.Triggers>
    </DataTemplate>
</ResourceDictionary>